package org.b3log.symphony.processor.wxs;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.b3log.latke.ioc.Inject;
import org.b3log.latke.servlet.HttpMethod;
import org.b3log.latke.servlet.RequestContext;
import org.b3log.latke.servlet.annotation.RequestProcessing;
import org.b3log.latke.servlet.annotation.RequestProcessor;
import org.b3log.latke.servlet.renderer.AbstractFreeMarkerRenderer;
import org.b3log.symphony.model.Common;
import org.b3log.symphony.processor.SkinRenderer;
import org.b3log.symphony.service.ArticleQueryService;
import org.json.JSONObject;

import java.util.Map;

@RequestProcessor
public class RestProcessor {

    @Inject
    private ArticleQueryService articleQueryService;

    private Logger logger = LogManager.getLogger(RestProcessor.class);

    @RequestProcessing(value = "/wxs/hot", method = HttpMethod.GET)
    public void showHot(final RequestContext context) {
        final AbstractFreeMarkerRenderer renderer = new SkinRenderer(context, "wxs/hot.ftl");
        final Map<String, Object> dataModel = renderer.getDataModel();
        final int sortMode=1;
        final int pageNum = 1;
        final int pageSize = 10;
        final JSONObject result = articleQueryService.getRecentArticles(sortMode, pageNum, pageSize);
        dataModel.put("articles", result.get("articles"));
    }
}
